Skip to content

Migrating Foundation to Swift 3 #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 8, 2016

Conversation

moiseev
Copy link
Contributor

@moiseev moiseev commented Mar 1, 2016

This branch is a result of running migrator on master and polishing it manually until it compiled on Linux.
Attempt to compile tests results in a weird error that needs further investigation.

}
if pwd != nil && pwd.pointee.pw_name != nil {
let name = String(cString: pwd.pointee.pw_name)
result[NSFileOwnerAccountName] = name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this logic changed? couldn't a string from c potentially be corrupted? I have seen that type of failure in C before why can't it happen here? Is this perhaps the wrong API to call if we want a failable C string conversion (without bouncing to CFStringRef/NSString, which can handle a failable conversion)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we're trying to avoid static factory methods and replace them with initializers. This particular initializer (init(cString:)) will try to repair ill-formed code units, which, we believe, is the behavior one would prefer by default (as opposed to the failing one). If you do prefer it to fail -- there is String.init?(validatingUTF8:).
Please note though, that both initializers will trap on nil.

@phausler
Copy link
Contributor

phausler commented Mar 1, 2016

What is the error you are running into? Is it a compilation failure or runtime?

@phausler
Copy link
Contributor

phausler commented Mar 1, 2016

@swift-ci Please test

@moiseev moiseev force-pushed the swift-3-api-guidelines branch from 033005f to 7334e70 Compare March 1, 2016 18:48
@moiseev
Copy link
Contributor Author

moiseev commented Mar 1, 2016

Rebased on top of current master to fix merge conflicts.

@phausler
Copy link
Contributor

phausler commented Mar 1, 2016

Thanks, we have gotten a bit behind in our PRs. Overall the changes look like they applied just fine so far. Is this blocked on any specific swift or XCTest PRs?

@moiseev
Copy link
Contributor Author

moiseev commented Mar 1, 2016

I tried to reproduce the compilation error I mentioned above this morning, but it just wasn't there. Right now I'm migrating XCTest, after which will migrate Foundation tests and update this PR.

@moiseev
Copy link
Contributor Author

moiseev commented Mar 1, 2016

@phausler made tests compile after migrating XCTest.
Seeing the following error now while running tests:
2__moiseev_rad_____ssh_

@phausler
Copy link
Contributor

phausler commented Mar 3, 2016

@moiseev can you run that with lldb and get me a backtrace? is that the only failure if you just disable that test?

@moiseev
Copy link
Contributor Author

moiseev commented Mar 3, 2016

I was going to do just that, haven't got time yet. Will try tomorrow morning.

@moiseev moiseev force-pushed the swift-3-api-guidelines branch from 22f67cc to 521a7be Compare March 3, 2016 22:46
@moiseev
Copy link
Contributor Author

moiseev commented Mar 3, 2016

Ok. So, I've commented out the test_xpath test and it all runs smoothly now. Also squashed migration commits into one and rebase on top of current master. If commenting test is OK for now, I'll consider it done and move forward towards finally making Swift 3 a new master. Does that sound like a plan, @phausler?

@parkera
Copy link
Contributor

parkera commented Mar 4, 2016

Good with me.

@phausler
Copy link
Contributor

phausler commented Mar 4, 2016

yea, all looks good. Filed https://bugs.swift.org/browse/SR-878 to follow up on the test_xpath issue; probably would be a decent starter bug too since it would start off with just uncommenting and debugging.

@moiseev moiseev force-pushed the swift-3-api-guidelines branch from 521a7be to 354fa65 Compare March 7, 2016 20:15
phausler added a commit that referenced this pull request Mar 8, 2016
@phausler phausler merged commit 4791d15 into swiftlang:master Mar 8, 2016
@moiseev
Copy link
Contributor Author

moiseev commented Mar 8, 2016

@phausler that was a bit too early, Swift master is not Swift 3 yet, neither is XCTest. Could you please revert this one?

@phausler
Copy link
Contributor

phausler commented Mar 8, 2016

ok sorry bout that, I thought we were good to go on this.

@moiseev
Copy link
Contributor Author

moiseev commented Mar 8, 2016

Thanks. I will send a new PR when we are actually ready.

On Mar 8, 2016, at 9:37 AM, Philippe Hausler notifications@github.com wrote:

ok sorry bout that, I thought we were good to go on this.


Reply to this email directly or view it on GitHub #271 (comment).

@moiseev
Copy link
Contributor Author

moiseev commented Mar 10, 2016

Rebased. Fixed. Tested. Ready for merge now.

@jessesquires jessesquires mentioned this pull request Mar 10, 2016
@moiseev
Copy link
Contributor Author

moiseev commented Mar 10, 2016

Oops. Commented here instead of #281.

atrick pushed a commit to atrick/swift-corelibs-foundation that referenced this pull request Jan 12, 2021
kateinoigakukun pushed a commit to kateinoigakukun/swift-corelibs-foundation that referenced this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants